import sys
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *

class LCDNumberDemo(QMainWindow):
    def __init__(self, parent=None):
        super(LCDNumberDemo, self).__init__(parent)

        # 创建LCDNumber控件
        self.lcd = QLCDNumber(self)
        self.lcd.setDigitCount(8)

        # 创建滑块
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setRange(0, 99999999)
        self.slider.setValue(0)
        self.slider.setTickPosition(QSlider.TicksBothSides)  # 修改为正确的枚举值
        self.slider.setTickInterval(1000)

        # 创建组合框
        self.lcd_style = QComboBox(self)
        self.lcd_style.addItem("Outline")
        self.lcd_style.addItem("Filled")
        self.lcd_style.addItem("Flat")

        # 链接信号与槽
        self.slider.valueChanged.connect(self.lcd.display)
        self.lcd_style.currentIndexChanged.connect(self.change_style)

        # 设置布局
        layout = QVBoxLayout()
        layout.addWidget(self.lcd)
        layout.addWidget(self.slider)
        layout.addWidget(self.lcd_style)

        main_frame = QWidget()
        main_frame.setLayout(layout)

        self.setCentralWidget(main_frame)
        self.setWindowTitle("QLCDNumber Example")
        self.resize(300, 200)

    def change_style(self, index):
        if index == 0:
            self.lcd.setSegmentStyle(QLCDNumber.Outline)
        elif index == 1:
            self.lcd.setSegmentStyle(QLCDNumber.Filled)
        elif index == 2:
            self.lcd.setSegmentStyle(QLCDNumber.Flat)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = LCDNumberDemo()
    window.show()
    sys.exit(app.exec())
